package com.gq.doremon;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

public class MoreAppActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		getWindow().requestFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.more_app_scr);
		final WebView webView = (WebView) findViewById(R.id.webview);
		final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
		webView.getSettings().setJavaScriptEnabled(true);
		webView.setWebViewClient(new WebViewClient() {

			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				if (processUrl(view, url)) return true;
				return super.shouldOverrideUrlLoading(view, url);
			}

			@Override
			public void onPageFinished(WebView view, String url) {
				webView.setVisibility(View.VISIBLE);
				progressBar.setVisibility(View.GONE);
				super.onPageFinished(view, url);
			}
			
		});
		
		webView.loadUrl("http://api.vietcntt.net/app/myapp");
		
	}
	
	public boolean processUrl(WebView view, String url) {
		if (url.startsWith("market://")) {
			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
			startActivity(intent);
			return true;
		}
		return false;
	}
	
}
